﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.CommonMethodServiceRef;

    public class GlobalInventoryRptQuery : BasePage
    {
        protected Button btnSearch;
        protected DropDownList ddlExtenalLotOper;
        protected DropDownList ddlOwnerIDOper;
        protected DropDownList ddlSkuClassIDOper;
        protected DropDownList ddlSkuID;
        protected DropDownList ddlSkuName;
        protected DropDownList ddlVendorIDOper;
        protected HtmlForm F13610;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlInputHidden hdnWh;
        protected HtmlHead Head1;
        protected Label lblExtenalLot;
        protected Label lblOwnerID;
        protected Label lblSkuClassID;
        protected Label lblSkuID;
        protected Label lblSkuName;
        protected Label lblVendorID;
        protected HtmlLink mycss;
        protected Label one1;
        protected TextBox txtExtenalLot;
        protected TextBox txtOwnerID;
        protected TextBox txtSkuClassID;
        protected TextBox txtSkuID;
        protected TextBox txtSkuName;
        protected TextBox txtVendorID;

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer("GlobalInventoryRptList.aspx", false);
        }

        public string GetUserWh()
        {
            List<WareHouseName4DDL> WareHouseName = new List<WareHouseName4DDL>();
            if (base.DataGridViewState != null)
            {
                WareHouseName = base.DataGridViewState as List<WareHouseName4DDL>;
            }
            else
            {
                WareHouseName = CommoneMethodServiceClientProxy.GetInstance().GetUserPermissionWareHouse();
                if ((WareHouseName != null) && (WareHouseName.Count > 0))
                {
                    base.DataGridViewState = WareHouseName;
                }
            }
            StringBuilder strHtml = new StringBuilder();
            if (WareHouseName.Count > 0)
            {
                strHtml.Append(" <tr><td colspan=4 >");
                foreach (WareHouseName4DDL info in WareHouseName)
                {
                    this.hdnWh.Value = this.hdnWh.Value + info.DbLoginID + ";";
                    strHtml.AppendFormat("<input id=\"cbk{0}\" type=\"checkbox\" onclick=\"CheckWh(this,'{2}');\" checked=\"true\" />{1}&nbsp;&nbsp;", info.WhDbID, info.WhDbDesc, info.DbLoginID);
                }
                strHtml.Append(" <td><tr>");
            }
            return strHtml.ToString();
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlSkuID, 0);
            base.InitQueryDDL(this.ddlOwnerIDOper, 0);
            base.InitQueryDDL(this.ddlVendorIDOper, 0);
            base.InitQueryDDL(this.ddlSkuName, 0);
            base.InitQueryDDL(this.ddlSkuClassIDOper, 0);
            base.InitQueryDDL(this.ddlExtenalLotOper, 0);
            base.InitQueryDDL(this.ddlVendorIDOper, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
            }
        }

        public string ExtenalLot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExtenalLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExtenalLot.Text, this.ddlExtenalLotOper.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string SkuClassID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuClassID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuClassID.Text.Trim(), this.ddlSkuClassIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string SkuDescr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuName.Text.Trim(), this.ddlSkuName.SelectedValue);
                }
                return "";
            }
        }

        public string SkuID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuID.Text.Trim(), this.ddlSkuID.SelectedValue);
                }
                return "";
            }
        }

        public string VendorID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorID.Text, this.ddlVendorIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string Wh
        {
            get
            {
                if (!string.IsNullOrEmpty(this.hdnWh.Value))
                {
                    return this.hdnWh.Value.Substring(0, this.hdnWh.Value.Length - 1);
                }
                return "";
            }
        }
    }
}

